home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_07 / ross / fclffind.c < prev    next >
C/C++ Source or Header  |  1995-05-01  |  525b  |  25 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. int fclfFind(int n, char *txt, int m, char *pat, int pos)
  4. { int i, j, k;
  5.   int nmatch = 0;
  6.   char *cp;
  7.   cp = strchr(txt, pat[pos]);
  8.   while (cp)
  9.   { i = cp - txt;
  10.     k = i - pos;
  11.     for (j=0; j<m && txt[k] == pat[j]; j++)
  12.  k++;
  13.     if (j == m)
  14.     { nmatch++;
  15.  printf("%d \n", i-pos);
  16.  cp = strchr(txt+i+m, pat[pos]);
  17.     }
  18.     else
  19.  cp = strchr(txt+i+1, pat[pos]);
  20.   }
  21.   return(nmatch);
  22. }
  23. Figure 5. First character, low frequency string searching function.
  24.  
  25.